#ifndef SERVER_H
#define SERVER_H

#include <QObject>
//需要在.pro中添加 QT += network
//Server继承自QTcpServer
#include <QTcpServer>
//Server类包含QList用来存储Client
#include "client.h"

class Server : public QTcpServer
{
    Q_OBJECT
public:
    Server(QObject * parent = 0, int port = 0);
    //QList存储Client对象线性表
    QList<Client *> clientList;

signals:
    //updateServer信号，与TcpServerUI的updateServer槽
    void updateServer(QString msg, int length);

public slots:
    //该槽与Client类的updateClients()信号绑定
    void updateClients(QString msg, int length);
    //该槽与Client类的disconnected()信号绑定
    void slotDisconnected(int);

protected:
    //incomingConnection()函数来自QTcpServer，虚函数
    //重写incomingConnection隐藏父类虚函数
    void incomingConnection(int clientDiscriptor);
};

#endif // SERVER_H
